﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Diablo_Character_Simulator.Enumerators;

namespace Diablo_Character_Simulator
{
    class Inventory
    {
        public List<Item> Items { get; private set; }

        public Inventory()
        {
            this.Items = new List<Item>();
        }

        public void Add(ItemSlot slot, List<ItemStat> stats, WeaponType weapType)
        {
            this.remove(slot);
            if (weapType != null)
                Items.Add(new Weapon(slot, stats, weapType));
            else
                Items.Add(new Item(slot, stats, ItemType.Armor));
            
            Character.OnItemUpdate();
        }

        private void remove(ItemSlot slot)
        {
            foreach (Item i in Items)
                if (i.Slot == slot)
                {
                    Items.Remove(i);
                    break;
                }
        }

        public void Remove(ItemSlot slot)
        {
            this.remove(slot);
            Character.OnItemUpdate();       
        }

        public void Reset()
        {
            this.Items = new List<Item>();
        }
    }
}
